package distributedbank.gui.messages;

import distributedbank.gui.BranchGui;

/**
 * Represents an error message sent to the gui to signal that a transaction
 * could not be performed because the destination JVM is not reachable due to
 * restrictions in the topology.
 */
public class ConnectionError
        extends Response {

    private static final long serialVersionUID = 1L;

    private final int remoteBranchId;
    private final int transactionId;

    public ConnectionError(int transactionId, int branchId, int remoteBranchId) {
        super(transactionId, branchId);
        this.remoteBranchId = remoteBranchId;
        this.transactionId = transactionId;
    }

    @Override
    public void runResponse(BranchGui gui) {
        gui.println("Error: Topology does not permit communicating with branch "
                + String.format("%02d", this.remoteBranchId)
                + " (transaction # " + this.transactionId + ")");
        // gui.blockGUI(false);
    }

}
